**************************************************************************************************
*** This do file creates the replication results for 
*** Inequalities of Income and Inequalities of Longevity: A Cross-Country Study 	 		 	*/
*** Eric Neumayer (LSE)																			*/
*** Thomas Pluemper (University of Essex)														*/
*** 																							*/
*** Published in: American Journal of Public Health (Published online ahead of print 
*** November 12, 2015: e1�e6. doi:10.2105/AJPH.2015.302849) 									*/
**************************************************************************************************
**************************************************************************************************
/* Note: 
You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 													*/
**************************************************************************************************

version 12.0
drop _all
clear matrix
clear mata


capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o)			/* checks whether outreg2 is installed 		*/

***********************************************************************************
local DIR = "d:\Research\Health for all database\Human mortality database\"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************

use "Article for AJPH.dta", clear
tsset countryid year


** Summary stats
quietly reg  gini_0_110 l.gini_0_110 e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol lung_mort_rate_comb_i external_mort_rate_comb_i income_gini_before_oecd_i  diff_before_after_gini_oecd   nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy i.year if country!="Chile",  cluster(country)
su gini_0_110 gini_10_110  e0 ln_gdp ln_tot_healthexp ln_alcohol  lung_mort_rate_comb_i external_mort_rate_comb_i income_gini_before_oecd_i  diff_before_after_gini_oecd   if e(sample)


** Table 1
* Entire life table
reg  gini_0_110 l.gini_0_110 e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol lung_mort_rate_comb_i external_mort_rate_comb_i income_gini_before_oecd_i  diff_before_after_gini_oecd   nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy i.year if country!="Chile",  cluster(country)
nlcom((_b[income_gini_before_oecd_i])/(1-_b[l.gini_0_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_0_110]))
outreg2 using table1, excel level(95) 2aster  dec(4) sideway ci  replace 

* Conditional on survival to age of 10 years
reg  gini_10_110 l.gini_10_110  e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol    lung_mort_rate_comb_i external_mort_rate_comb_i income_gini_before_oecd_i  diff_before_after_gini_oecd  nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy  i.year if country!="Chile",  cluster(country)
nlcom((_b[income_gini_before_oecd_i])/(1-_b[l.gini_10_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_10_110]))
outreg2 using table2, excel level(95) 2aster  dec(4) sideway ci  replace 



** Online appendix

* Table A1

* model 1
reg  gini_0_110 l.gini_0_110 e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol lung_mort_rate_comb_i external_mort_rate_comb_i income_gini_before_oecd_i  diff_before_after_gini_oecd   nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy i.year if country!="Chile",  cluster(country)
nlcom((_b[income_gini_before_oecd_i])/(1-_b[l.gini_0_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_0_110]))
outreg2 using table1, excel level(95) 2aster  dec(4) sideway ci  replace 

* model 2
reg  gini_0_110 l.gini_0_110 e0  c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol    lung_mort_rate_comb external_mort_rate_comb income_gini_before_oecd  diff_before_after_gini_oecd   nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy i.year if country!="Chile",  cluster(country)
nlcom((_b[income_gini_before_oecd])/(1-_b[l.gini_0_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_0_110]))
outreg2 using table1, excel level(95) 2aster  dec(4) sideway ci  append 

* model 3
reg  gini_0_110 l.gini_0_110  e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol  lung_mort_rate_comb_i external_mort_rate_comb_i income_gini_before_oecd_i  diff_before_after_gini_oecd   nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy i.year if oecd_dum_core==1,  cluster(country)
nlcom((_b[income_gini_before_oecd_i])/(1-_b[l.gini_0_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_0_110]))
outreg2 using table1, excel level(95) 2aster  dec(4) sideway ci  append 

* model 4
reg  gini_0_110 l.gini_0_110   e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol  lung_mort_rate_comb_i external_mort_rate_comb_i  income_gini_before_oecd_i  diff_before_after_gini_oecd  nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy i.year if oecd_dum_core==1 & country!="United States",  cluster(country)
nlcom((_b[income_gini_before_oecd_i])/(1-_b[l.gini_0_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_0_110]))
outreg2 using table1, excel level(95) 2aster  dec(4) sideway ci  append 


* Table A2

* model 5
reg  gini_10_110 l.gini_10_110  e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol    lung_mort_rate_comb_i external_mort_rate_comb_i income_gini_before_oecd_i  diff_before_after_gini_oecd  nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy  i.year if country!="Chile",  cluster(country)
nlcom((_b[income_gini_before_oecd_i])/(1-_b[l.gini_10_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_10_110]))
outreg2 using table2, excel level(95) 2aster  dec(4) sideway ci  replace 

* model 6
reg  gini_10_110 l.gini_10_110 e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol lung_mort_rate_comb external_mort_rate_comb income_gini_before_oecd  diff_before_after_gini_oecd   nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy i.year if country!="Chile",  cluster(country)
nlcom((_b[income_gini_before_oecd])/(1-_b[l.gini_10_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_10_110]))
outreg2 using table2, excel level(95) 2aster  dec(4) sideway ci  append 

* model 7
reg  gini_10_110 l.gini_10_110  e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol   lung_mort_rate_comb_i external_mort_rate_comb_i income_gini_before_oecd_i  diff_before_after_gini_oecd  nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy  i.year if oecd_dum_core==1,  cluster(country)
nlcom((_b[income_gini_before_oecd_i])/(1-_b[l.gini_10_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_10_110]))
outreg2 using table2, excel level(95) 2aster  dec(4) sideway ci  append 

* model 8
reg  gini_10_110 l.gini_10_110   e0 c.ln_gdp##c.ln_gdp c.ln_tot_healthexp##c.ln_tot_healthexp ln_alcohol  lung_mort_rate_comb_i external_mort_rate_comb_i  income_gini_before_oecd_i  diff_before_after_gini_oecd  nhs_dummy nhi_dummy shi_dummy ehi_1_dummy ehi_2_dummy other_east_europe_dummy i.year if oecd_dum_core==1 & country!="United States",  cluster(country)
nlcom((_b[income_gini_before_oecd_i])/(1-_b[l.gini_10_110]))
nlcom((_b[diff_before_after_gini_oecd])/(1-_b[l.gini_10_110]))
outreg2 using table2, excel level(95) 2aster  dec(4) sideway ci  append 
